package samsung.sds.survey.surveyList.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import samsung.sds.survey.surveyList.service.SurveyListService;
import samsung.sds.survey.surveyManagement.model.SurveyEntity;
import samsung.sds.system.common.baseQuery.model.PageData;
import samsung.sds.system.common.model.QueryParam;
import samsung.sds.system.utils.CommonTools;

/**
 * @author tingcai.liu
 * @createDate 2016-01-12
 * 
 * 投票信息Controller
 */
@Controller
@RequestMapping("/survey/surveyList")
public class SurveyListController {

	@Autowired
	private SurveyListService surveyListServiceImpl;
	
	/**
	 * 跳转到问卷列表页面
	 * @param type
	 * @param request
	 * @param modelMap
	 * @return
	 */
	@RequestMapping(value = "/loadSurveyList", method = RequestMethod.POST)
	public String loadSurveyList(HttpServletRequest request,ModelMap modelMap){
		String type = request.getParameter("type");
		modelMap.addAttribute("type", type);
		modelMap.addAttribute("currentPage", request.getParameter("currentPage"));
		return "/survey/surveyList/surveyList";
	}
	
	/**
	 * 分页获取用户列表
	 * @param request
	 * @param modelMap
	 * @return
	 */
	@RequestMapping(value = "/getSurveyList", method = RequestMethod.POST)
	@ResponseBody
	public PageData<SurveyEntity> getSurveyList(HttpServletRequest request){
		QueryParam param = CommonTools.getQueryParam(request);
		return surveyListServiceImpl.queryListPage(param);
	}
}
